<template>
	<view class="agreement-box">
		<image class="agreement-check" :src="isSelect ? '/static/login_check_p.png' : '/static/login_check_n.png'" mode="aspectFit" @tap="agreeAction"></image>
		<view class="agreement-text-box">
			<text>已经阅读并同意</text>
			<text class="agreement-text-blue" @tap="showAgreementInfo(1)">《用户协议》</text>
			<text class="agreement-text-blue" @tap="showAgreementInfo(2)">《隐私政策》</text>
			<text>及</text>
			<text class="agreement-text-blue" @tap="showAgreementInfo(3)">《CFCA数字证书服务协议》</text>
		</view>
	</view>
</template>

<script setup>
	import { app_user_agreement,app_user_privacy,app_user_cfca } from '@/config/config.js'
	const emits = defineEmits(['agree'])
	const props = defineProps({
		isSelect:{
			type:Boolean,
			default:false
		}
	})
	///同意/取消协议
	const agreeAction = ()=>{
		emits('agree',props.isSelect ? false : true)
	}
	//查看协议信息
	const showAgreementInfo = (type)=>{
		if (type == 1) {
			uni.navigateTo({
				url: `/pages/webview/webview?title=用户协议&url=${app_user_agreement()}`
			})
		}
		else if (type == 2) {
			uni.navigateTo({
				url: `/pages/webview/webview?title=隐私政策&url=${app_user_privacy()}`
			})
		}
	    else {
			uni.navigateTo({
				url: `/pages/webview/webview?title=CFCA数字证书服务协议&url=${app_user_cfca()}`
			})
		}
	}
	
</script>

<style lang="scss" scoped>
.agreement-box{
	display: flex;
	align-items: flex-start;
	font-size: 26rpx;
	color: $xh-subtitle-color;
	.agreement-check{
		width: 26rpx;
		height: 26rpx;
		padding: 5rpx;
		flex-shrink: 0;
	}
	.agreement-text-box{
		text:nth-child(1){
			margin-left: 10rpx;
		}
		.agreement-text-blue{
			color: $xh-blue-color;
		}
	}
}
</style>